import Vue from 'vue';
import Router from 'vue-router';
import { constantRoutes } from './routes';
Vue.use(Router);

// 创建路由对象
const createRouter = () => new Router({
    // 路由模式 hash
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRoutes,
    // 可以不写，默认采用 hash 模式
    mode: 'hash'
});

// 路由对象实例化
const router = createRouter();

// 路由重置
export function resetRouter() {
    const newRouter = createRouter();
    // 路由重置
    router.matcher = newRouter.matcher;
}

console.log('constantRoutes>>', constantRoutes);

export default router;